/**
 * 
 * 
 */


import { EPokerStatus, Esuit } from "../../ConfigEnum";
import { Poker } from "../../GameScene/GameDB";



 
const  Point_map=
{
  "1":"1",
  "2":"2",
  "3":"3",
  "4":"4",
  "5":"5",
  "6":"6",
  "7":"7",
  "8":"8",
  "10":"10",
  "11":"J",
  "12":"Q",
  "13":"K",
}
 const { ccclass,property } = cc._decorator;

 @ccclass
 export default class UIPoker extends cc.Component{
     
     @property(cc.Label)  pointLaber:cc.Label=null;
     @property(cc.Sprite)  SmallSuitSprite:cc.Sprite=null;
     @property(cc.Sprite)  BigSuitSprite:cc.Sprite=null;
     @property(cc.Sprite)  BgSprite:cc.Sprite=null;

     @property(cc.SpriteFrame) texFrontBG:cc.SpriteFrame=null;
     @property(cc.SpriteFrame)  texBackBG:cc.SpriteFrame=null;
     @property(cc.SpriteFrame) BigSuit:cc.SpriteFrame[]=[]
     @property(cc.SpriteFrame) SmallSuit:cc.SpriteFrame[]=[];
     @property(cc.SpriteFrame) texFaces:cc.SpriteFrame[]=[];


     private redTextColor:cc.Color=cc.Color.RED;
     private blackTextColor:cc. Color=cc.Color.BLACK;

    
     public Init(poker:Poker)
     {
           //this.laber_.string=' (点数: ${poker.point_} 花色: ${poker.suit_} )';
          // this.laber_.string='(${poker.point_}, ${poker.suit_})';
          //this.pointLaber.string='(点数:' +poker.point_+ '花色'+ poker.suit_ +')';
          this.pointLaber.node.color=(poker.suit_==Esuit.HEITAO||poker.suit_==Esuit.MEIHUA)?this.blackTextColor:this.redTextColor;
          this.pointLaber.string=Point_map[poker.point_];
          if(poker.point_>=11)
          {
            this.BigSuitSprite.spriteFrame=this.texFaces[poker.point_-11]
          }else{
            this.BigSuitSprite.spriteFrame=this.BigSuit[poker.suit_];
          }
         
          this.SmallSuitSprite.spriteFrame=this.SmallSuit[poker.suit_];
          this.setStatus(poker.status);
     }
    
     private setStatus(status:EPokerStatus){
         if(status==EPokerStatus.CLOSE)
         {
           this.pointLaber.node.active=false;
           this.SmallSuitSprite.node.active=false;
           this.BigSuitSprite.node.active=false;
           this.BgSprite.spriteFrame=this.texBackBG;
         }else
         {
          this.pointLaber.node.active=true;
          this.SmallSuitSprite.node.active=true;
          this.BigSuitSprite.node.active=true;
          this.BgSprite.spriteFrame=this.texFrontBG;
         }
     }
 }
 